import { ref } from "vue";
import LocalCache from "@/utils/storage";
export const theme = ref('')

export const setTheme = (val: string) => {
  if (val === 'dark') {
    document.body.setAttribute('arco-theme', val)
  }
  else {
    document.body.removeAttribute('arco-theme');
  }
  theme.value = val
  LocalCache.set('theme', val)
}

export const loadTheme = () => {
  theme.value = LocalCache.get('theme') || ''
  setTheme(theme.value)
}